package zyx20230706;

import javax.swing.*;
import java.awt.*;

public class MFrame extends JPanel {
    public Shape[] shapeArr;
    public Color color;
    //重写组件的paint方法
    public void paint(Graphics g){
        //1.保留绘制组件的功能：调用父类的paint方法
        //super 表示当前类的父类对象
        super.paint(g);
        g.setColor(color);

        //2.重绘图形
        for(int i=0;i<shapeArr.length;i++){
            Shape shape = shapeArr[i];
            if(shape != null){
                shape.drawShape(g);

            }
        }

    }
}
